<template>
  <view>
    <l-form-cell label="交强险到期时间" has-slot :must="must" :arrow="!disabled" @click="changeDate('compulsoryInsExp')">
      <view class="form-item flex-row flex-item align-center justify-end">
        <text class="text-30" :class="['color-t' + (form.compulsoryInsExp ? 1 : 3)]">{{ form.compulsoryInsExp || '请选择日期' }}</text>
      </view>
    </l-form-cell>
    <l-form-cell label="承运人险到期时间" has-slot :must="must" :arrow="!disabled" label-width="240rpx" @click="changeDate('carrierInsExp')">
      <view class="form-item flex-row flex-item align-center justify-end">
        <text class="text-30" :class="['color-t' + (form.carrierInsExp ? 1 : 3)]">{{ form.carrierInsExp || '请选择日期' }}</text>
      </view>
    </l-form-cell>
    <l-form-cell v-if="must" v-model="form.remark" label="备注" placeholder="请输入备注" unlined />
    <l-form-cell v-else label="商业险到期时间" has-slot :must="must" unlined :arrow="!disabled" @click="changeDate('commerceInsExp')">
      <view class="form-item flex-row flex-item align-center justify-end">
        <text class="text-30" :class="['color-t' + (form.commerceInsExp ? 1 : 3)]">{{ form.commerceInsExp || '请选择日期' }}</text>
      </view>
    </l-form-cell>
  </view>
</template>

<script>
export default {
  name: 'InsuranceInfoModel',
  props: {
    data: {
      type: Object,
      default: () => {}
    },
    must: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    },
    status: {
      type: [String, Number],
      default: 0
    }
  },
  data() {
    return {
      form: {
        compulsoryInsExp: '',
        carrierInsExp: '',
        commerceInsExp: ''
      }
    }
  },
  watch: {
    data: {
      handler(e) {
        Object.assign(this.form, e)
      },
      deep: true
    },
    form: {
      handler() {
        this.$emit('update', this.form)
      },
      deep: true
    }
  },
  methods: {
    // 修改日期
    changeDate(attr) {
      this.$emit('changeDate', attr)
    }
  }
}
</script>

<style scoped>

</style>
